const express = require("express");
const app = express();
// body-parser解析post请求中的body参数
const bodyParser = require("body-parser");
// 引入数据库
const db = require('./db/index');
const Students = require('./models/student');
app.use(bodyParser.urlencoded({
    extended: true
}));
// 引入路由器模块
const test1 = require('./routes/test1');
const test2 = require('./routes/test2');
// 应用路由
app.use(test1);
app.use(test2);
// 路由
app.get("/test", async (req, res) => {
    // 数据库连接
    await db;
    // 数据的增删改查
    // 添加数据
    const result = await Students.create({
        name: 'tianqing',
        age: 18,
        info: '过年涨了几斤'

    })
    console.log(result);
    res.send("xxx");
});
app.listen(3000, err => {
    if (!err) console.log("服务器启动！！");
    else console.log(err);
});